//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.cloud.logger.zchain.spring.interceptor;

import com.cloud.logger.zchain.core.common.properties.ServerInfo;
import com.cloud.logger.zchain.core.zookeeper.LeaderElection;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MutexHandlerInterceptor {
    public MutexHandlerInterceptor() {
    }

    @Around("execution(* *(..)) && @annotation(com.cloud.logger.zchain.spring.annotation.Mutex)")
    public Object invoke(ProceedingJoinPoint pjp) throws Throwable {
        String leader = LeaderElection.getLeader();
        return leader != null && leader.equals(ServerInfo.scheduleNode) ? pjp.proceed() : false;
    }
}
